package com.liwei.controller;

import com.liwei.dto.ResultDTO;
import com.liwei.exception.MyLengthException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
//全局异常处理能力
@RestControllerAdvice
public class MyLengthExceptionController  {
    @ExceptionHandler(MyLengthException.class)
    public ResultDTO myLengthExceptionController(MyLengthException e){
        ResultDTO resultDTO = new ResultDTO();
        resultDTO.setResult(resultDTO.ERROR);
        resultDTO.setError(e.getMessage());
        return resultDTO;
    }
}
